<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/common/default.jsp"%>
<html>
	<head>
	    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<style type="text/css">
			.select_option{
				width: 180px;
				z-index: 1;
				position: absolute;
			}
			.select_showbox{
				width: 175px;
			}
		</style>
		<link type="text/css" rel="stylesheet" href="${ctx}/static/tools/jquery-validationEngine/validationEngine.jquery.css"></link>
	</head>
	<body>
		<script type="text/javascript" src="${ctx}/static/tools/jquery-validationEngine/jquery.validationEngine.js"></script>
		<script type="text/javascript" src="${ctx}/static/tools/jquery-validationEngine/jquery.validationEngine-cn.js"></script>
		<div class="cinema_tip">
		    <div class="cinema_subject clearfix">
		        <div class="cinema_title">
		            <a href="javascript:void(0);">项目管理</a> >
		            <a id="userinfo_list_href" href="${ctx}/sys/sysProjectMan/SectionInfo/toSearch">工段信息</a> >
		            <a href="javascript:void(0);" class="cinema_option">编辑工段信息</a>
		        </div>
		        <!-- <a onclick="javascript:history.back(-1);" class="movie_return">返回列表</a> -->
		        <a href="${ctx}/sys/sysProjectMan/SectionInfo/toSearch" class="movie_return">返回列表</a>
		    </div>
		</div>
		<div class="cinema_list">
			<form class="form-horizontal" onsubmit="return sysSecInfoModify();" id="sysSecInfoModifyForm"  name="sysSecInfoModifyForm" >
				<input type="hidden" id="secId" name="secId" value="${sysSecInfo.secId}">
				<div class="movie_list">
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">工段所属项目: </p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed positionSelect">
								<select id="proId" name="proId" onchange="show(this.options[this.options.selectedIndex].value)">
									<option class="department_opt" value="">选择项目</option>
									<c:forEach var="res" items="${projects.data}">
										<option class="department_opt" value="${res.proId }" <c:if test="${res.proId == sysSecInfo.proId}">selected</c:if>>${res.name }</option>
									</c:forEach>
								</select>
							</div>
						</dd>
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p>工段编号：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="segCode" type="text" name="segCode" value="${sysSecInfo.segCode}" class="validate[required,maxSize[100]]" maxlength="100" />
							</div>
						</dd>
					</dl>
					<div class="clearfix"></div>
				
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p>工段名称：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="name" type="text" name="name" value="${sysSecInfo.name}" class="validate[required,maxSize[100]]" maxlength="100" />
							</div>
						</dd>
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p>工段负责人：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="leader" type="text" name="leader" value="${sysSecInfo.leader}" class="validate[required,maxSize[100]]" maxlength="100" />
							</div>
						</dd>
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">工段所在地 ：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="district" type="text" name="district" value="${sysSecInfo.district}" class="width_320" maxlength="100" />
							</div>
						</dd>
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">物资部负责人 ：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="suppliesLeader" type="text" name="suppliesLeader" value="${sysSecInfo.suppliesLeader}" class="width_320" maxlength="100" />
							</div>
						</dd>
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">计划部负责人 ：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="planLeader" type="text" name="planLeader" value="${sysSecInfo.planLeader}" class="width_320" maxlength="100" />
							</div>
						</dd>
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">工段状态: </p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed positionSelect">
								<select id="status" name="status">
									<option class="department_opt" value="">选择工段状态</option>
										<option class="department_opt" value="1" <c:if test="${sysSecInfo.status ==1}">selected</c:if>>未开工</option>
										<option class="department_opt" value="2" <c:if test="${sysSecInfo.status ==2}">selected</c:if>>已开工</option>
										<option class="department_opt" value="3" <c:if test="${sysSecInfo.status ==3}">selected</c:if>>已完工</option>
								</select>
							</div>
						</dd>
					</dl>
					
					<div class="clearfix"></div>
					<a class="movie_continue">
						<input type="submit" name="submit" id="submit" value="提交" class="cinema_inquiry" />
					</a>
				</div>
			</form>
		</div>
		<script type="text/javascript">
		
		function show(v){
			alert(v);
		}
		
			//项目基本信息修改
			function sysSecInfoModify(){
				if($("#sysSecInfoModifyForm").validationEngine("validate")){
					
					var datastr = new Object();
					datastr.secId = $('#secId').val();
					datastr.segCode = $('#segCode').val();
	    			datastr.name = $('#name').val();
	    			datastr.proId = $('#proId').val();
	    			datastr.proName=$("#proId").find("option:selected").text();
	    			datastr.district = $('#district').val();
	    			datastr.leader = $('#leader').val();
	    			datastr.suppliesLeader = $('#suppliesLeader').val();
	    			datastr.planLeader = $('#planLeader').val();
	    			datastr.status = $('#status').val();
	    			
					var result = true;
					$.ajax({
	    		        async: true,
	    		        type:"POST",
	    		        data:JSON.stringify(datastr),
	    		        url: "${ctx}/sys/sysProjectMan/SectionInfo/modify?&mid="+Math.random(),
	    		        dataType: "json",
	    		        headers : {  
	                        'Content-Type' : 'application/json;charset=utf-8'  
	                    },
	                    
	                    success : function(data) {
	                		if (data != undefined && data.status != undefined
	                				&& data.status.trim() == '0') {
	                			result = true;
	                			alert("修改成功！");
	                			window.location.href = "${ctx}/sys/sysProjectMan/SectionInfo/toSearch";
	                		} else {
	                			result = false;
	                			alert(data.error);
	                		}
	                	},
	    			},"json");
					
				}
				return false;
			}
			$("#sysSecInfoModifyForm").validationEngine();
		</script>
	</body>
</html>